<?php
if (isset($_SESSION['cart'])) {
    ?>
    <style>
        table, td, th
        {
            border-collapse:collapse;
            border: 1px #000000 solid;

        }

        table {
            width: 100%;
        }
    </style>
    <form name="update" action="" method="post" >
        <table >
            <tr>
                <th style="width: 50px;">No</th>
                <th>Tên Mặt Hàng</th>
                <th>Số Lượng</th>
                <th>Đơn Giá</th>
                <th>Thành Tiền</th>        
            </tr>
            <?php
            $i = 1;
            $sumTotal = 0;
            foreach ($_SESSION['cart'] as $key => $value) {
                ?>
                <tr>
                    <td align="center"><?php echo $i; ?></td>
                    <td><?php echo $value['tenMH'] ?></td>
                    <td align="center">
                        <input type="text" name="cart[<?php echo $key; ?>]" value="<?php echo $value['soluong'] ?>" style="text-align: right" />

                    </td>
                    <td align="right"><?php echo $value['giaMH'] ?></td>
                    <td align="right">
                        <?php
                        $total = $value['soluong'] * $value['giaMH'];
                        echo $total;
                        ?>
                    </td>        
                </tr>
                <?php
                $sumTotal += $total;
                $i++;
            }
            ?>
            <tr>
                <td colspan="4" align="right">
                    Tong Cong 
                </td>
                <td align="right">
                    <?php echo $sumTotal; ?>
                </td>
            </tr>
        </table>
        <div align="center">
            <input type="submit" name="ok" value="Update" />
            <input type="button" name="thanhtoan" value="Thanh Toán" 
                   onclick="window.location.href='index.php?mod=thanhtoan'" />
        </div>
    </form>
    <?php
} else {
    echo 'Giỏ hàng trống';
}